// 统一的登录状态检查工具
const checkLoginStatus = () => {
  const token = wx.getStorageSync("token");
  const userInfo = wx.getStorageSync("userInfo");
  return !!token && !!userInfo;
};

// 获取用户信息
const getUserInfo = () => {
  return wx.getStorageSync("userInfo") || null;
};

// 保存登录状态
const saveLoginStatus = (token, userInfo) => {
  wx.setStorageSync("token", token);
  wx.setStorageSync("userInfo", userInfo);
};

// 清除登录状态
const clearLoginStatus = () => {
  wx.removeStorageSync("token");
  wx.removeStorageSync("userInfo");
};

module.exports = {
  checkLoginStatus,
  getUserInfo,
  saveLoginStatus,
  clearLoginStatus,
}; 